package com.zb.zbtcommon.controller;

import com.zb.zbtcommon.dto.ResponseEntity;
import com.zb.zbtcommon.entity.Link;
import com.zb.zbtcommon.service.LinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/zbt/common/link")
@Api(value = "LinkController")

public class LinkController {
    private Logger logger = LoggerFactory.getLogger(LinkController.class);
    @Autowired
    private LinkService LinkService;

    @RequestMapping("findLinklist")
    @ApiOperation("查询数据")
    @ApiImplicitParam(paramType="query", name = "linktypeid", value = "ID类型linktypeid", required = true, dataType = "String")
    public ResponseEntity<Link> findLinklist(String linktypeid){

        ResponseEntity entity=null;
        try {
            entity=new ResponseEntity();
            List<Link> list=LinkService.findLink(linktypeid);
            entity.setCode(HttpStatus.OK.value());
            entity.setTarget(list);
        } catch (Exception e) {

            logger.error("/zbt/common/link/findlinklist   请求参数：无  异常信息"+e.getMessage());
            e.printStackTrace();
            entity.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
            entity.setMessage("查询数据错误");
        }
        return entity;

    }

}
